package oop第三章作业;

import javax.print.DocFlavor;
import java.util.Scanner;

public class Student {
   private String  name;
    private int age;
   private   String  gender;
    public  void setName(String  name){
        this.name=name;
    }
    public String  getName(){
        return name;

    }
    public  int getAge(){
        return age;

    }
    public void  setAge( int age){
        if (age<1||age>100){
            System.out.println("你输入的年龄不合法");
            this.age=18;
        }else {
            this.age=age;
        }
    }
    public  String  getGender(){
        return  gender;
    }
    public void  setGender(String  gender){
        if ( gender.equals("男")||gender.equals("女")){
            this.gender=gender;
        }else {
            System.out.println("您输入的性别有误！");
            this.gender="男";
        }
    }
    public Student( String  name, int age ,String  gender){
        this.gender=gender;
        this.name=name;
        this.age=age;
    }
    public Student(){
    }
    public  void  say(){
        System.out.println(this.name+this.gender+"今年"+this.age+"岁");
    }
    public static void main(String[] args) {
         Student student=new Student("周鹏",19,"男");
         student.setAge(19);
         student.setGender("男");
         student.setName("周鹏");
         student.say();
    }
}
